<?php


namespace app\cms\admin\controller\nav;


use app\cms\model\admin\adminUserNavModel;
use iflow\auth\Authorize\AuthAnnotation;
use iflow\Container\implement\annotation\tools\data\Inject;
use iflow\Response;
use iflow\router\Controller;
use iflow\Router\implement\Request\{ GetMapping, PostMapping, DeleteMapping };

#[Controller('%cmsAdmin%/admin_user_nav')]
class adminUserNavController
{

    #[Inject]
    public adminUserNavModel $adminUserNavModel;

    /**
     * 获取管理员用户左侧导航栏
     * @param int $uid
     * @param int $nav_group_id
     * @return Response
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    #[GetMapping]
    #[AuthAnnotation('getUserInfo', 'adminUser')]
    public function getAdminUserNav(int $uid, int $nav_group_id): Response
    {
        $nav = $this->adminUserNavModel -> getNavListByUidAndNavGroupId($uid, $nav_group_id);
        if (!$nav) return message() -> nodata('暂无数据');
        return message() -> success('查询成功', $nav);
    }


    #[PostMapping]
    #[AuthAnnotation('getUserInfo', 'adminSetUserNav')]
    public function setAdminUserNav(int $uid, int $nav_group_id, int $nav_id): Response
    {
        return $this->adminUserNavModel -> setAdminUserNav($uid, $nav_group_id, $nav_id);
    }

    #[DeleteMapping]
    #[AuthAnnotation('getUserInfo', 'adminSetUserNav')]
    public function deleteAdminUserNav(int $uid, int $nav_group_id, int $nav_id): Response
    {
        return $this->adminUserNavModel -> deleteAdminUserNav($uid, $nav_group_id, $nav_id);
    }


}